#include "StdAfx.h"
#include "../Engine/TileWalker.hpp"

namespace he
{
	std::pair<int, int> TileWalker::get_tile(int X, int Y, Direction Dir) 
	{
		std::pair<int, int> destination(X, Y);
		switch(Dir)
		{
		case NORTH:
			destination.second -= 2;
			break;
		case NORTH_EAST:
			--destination.second;
			destination.first += (Y & 1);
			break;
		case EAST:
			++destination.first;
			break;
		case SOUTH_EAST:
			++destination.second;
			destination.first += (Y & 1);
			break;
		case SOUTH:
			destination.second += 2;
			break;
		case SOUTH_WEST:
			++destination.second;
			destination.first += (Y & 1) - 1;
			break;
		case WEST:
			--destination.first;
			break;
		case NORTH_WEST:
			--destination.second;
			destination.first += (Y & 1) - 1;
			break;
		}

		return destination;
	}

	std::pair<int, int> TileWalker::get_tile(int X, int Y, Direction Dir, unsigned char Step)
	{
		std::pair<int, int> tile_pair(X, Y);
		for(unsigned short i = 0; i < Step; ++i)
			tile_pair = get_tile(tile_pair.first, tile_pair.second, Dir);
		
		return tile_pair;
	}

}